<template>
  <div>
    Home page
    <h2>{{ message }}</h2>

    <!-- 当我们在template模板中使用ref对象，会自动进行解包 -->
    <h2>当前计数: {{ counter }}</h2>
    <!-- ref的解包只能是浅层解包，info是一个普通的javascript对象-->
    <h2>当前计数: {{ info.counter.value }}</h2>
    <!-- 当如果最外层包裹的是一个reactive可响应式对象，那么内容的ref可以解包 -->
    <h2>当前计数: {{ reactiveInfo.counter }}</h2>
    <button @click="increment">点击按钮+1</button>


  </div>
</template>

<script>
import { reactive,ref } from "vue";
export default {
  props: {
    message: {
      type: String,
      required: true,
    },
  },
  setup() {
    let counter = ref(100);
    const info = {
      counter
    }
    const reactiveInfo = reactive({
      counter
    })

    const increment = () => {
      counter.value++;
      console.log(counter.value, "increment");
    };
    return {
      title: "Hello Vue3",
      counter,
      info,
      reactiveInfo,
      increment,
    };
  },
};
</script>

<style scoped>
</style>